
/*
 * Copyright 2002-2016 the original author or authors.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      https://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
/*
 *版权所有2002-2016原作者。
 *
 *根据Apache许可证2.0版许可（“许可证”）；
 *除非符合许可证的规定，否则您不得使用此文件。
 *您可以在以下网址获取许可证副本：
 *
 *https://www.apache.org/licenses/LICENSE-2.0
 *
 *除非适用法律要求或书面同意，软件
 *根据许可证进行的分发是在“按原样”的基础上进行的，
 *无任何明示或暗示的保证或条件。
 *有关管理权限的特定语言，请参阅许可证
 *许可下的限制。
 */

package org.springframework.mail.javamail;

import jakarta.mail.internet.MimeMessage;

/**
 * Callback interface for the preparation of JavaMail MIME messages.
 *
 * <p>The corresponding {@code send} methods of {@link JavaMailSender}
 * will take care of the actual creation of a {@link MimeMessage} instance,
 * and of proper exception conversion.
 *
 * <p>It is often convenient to use a {@link MimeMessageHelper} for populating
 * the passed-in MimeMessage, in particular when working with attachments or
 * special character encodings.
 * See {@link MimeMessageHelper MimeMessageHelper's javadoc} for an example.
 *
 * @author Juergen Hoeller
 * @since 07.10.2003
 * @see JavaMailSender#send(MimeMessagePreparator)
 * @see JavaMailSender#send(MimeMessagePreparator[])
 * @see MimeMessageHelper
 */
/**
 *用于准备JavaMail MIME消息的回调接口。
 *
 *<p>｛@link JavaMailSender｝的相应的｛@code send｝方法
 *将负责{@link MimeMessage}实例的实际创建，
 *以及正确的异常转换。
 *
 *＜p＞使用｛@link MimeMessageHelper｝进行填充通常很方便
 *传入的MimeMessage，尤其是在处理附件或
 *特殊字符编码。
 *有关示例，请参阅｛@link MimeMessageHelper MimeMessageHelp的javadoc｝。
 *
 *@作者Juergen Hoeller
 *@自2003年10月7日起
 *@seeJavaMailSender#send（MimeMessagePreparator）
 *@see JavaMailSender#send（MimeMessagePreparator[]）
 *@see MimeMessageHelper
 */
@FunctionalInterface
public interface MimeMessagePreparator {

	/**
	 * Prepare the given new MimeMessage instance.
	 * @param mimeMessage the message to prepare
	 * @throws jakarta.mail.MessagingException passing any exceptions thrown by MimeMessage
	 * methods through for automatic conversion to the MailException hierarchy
	 * @throws java.io.IOException passing any exceptions thrown by MimeMessage methods
	 * through for automatic conversion to the MailException hierarchy
	 * @throws Exception if mail preparation failed, for example when a
	 * FreeMarker template cannot be rendered for the mail text
	 */
	/**
	 *准备给定的新MimeMessage实例。
	 *@param mimeMessage要准备的消息
	 *@sthrows jakarta.mail.MessagingException传递MimeMessage引发的任何异常
	 *方法到，用于自动转换到MailException层次结构
	 *@throws java.io.IOException传递MimeMessage方法引发的任何异常
	 *到以自动转换到MailException层次结构
	 *如果邮件准备失败，则@throws异常，例如当
	 *无法为邮件文本呈现FreeMarker模板
	 */
	void prepare(MimeMessage mimeMessage) throws Exception;

}
